<!-- Student Applications -->
<div class="widfats" style="width:90%;">
    <div class="widget" id="widget_students_jobs">
        <div class="toggle">&nbsp;</div>
        <h3 class="handle"><?php __('My Applied Jobs'); ?></h3>
        <div class="content">
        <?php $jobs = $student['Job']; ?>
        <?php if(count($jobs) > 1): ?>
            <!-- to avoid two loops over the same array -->
            <ul class="tabs">
                <?php foreach($jobs as $i=>$job): ?>
                    <li class="job_title" target="#job_content_<?php e($job['id']); ?>">
                        <a href="javascript:void(0)"><?php e($job['title']); ?></a>
                    </li>
                <?php endforeach; ?>
            </ul>
            <!-- loop to create titles and job contents -->
            <div class="panes">
                <?php foreach($jobs as $i=>$job): ?>
                    <div class="job_content" id="job_content_<?php e($job['id']); ?>">
                        <?php e($this->element('view_job',
                            array(
                                'job'=>array('Job'=>$job),
                                'company'=>array('Company'=>$job['Company']),
                                'action' => 'antiapply'
                            )
                        )); ?>
                    </div>
                <?php endforeach; ?>
            </div>

        <?php elseif(count($student['Job']) ==1): ?>
            <?php e($this->element('view_job',
                array(
                    'job'=>array('Job'=>$jobs[0]),
                    'company'=>array('Company'=>$jobs[0]['Company']),
                    'action' => 'antiapply'
                )
            )); ?>
        <?php else: ?>
            <?php if(!$student['Student']['resume']): ?>
                <p><?php __('No resume yet, go to the quick actions section to add one'); ?></p>
                <?php e($html->link(__('New StudentResume', true),
                    array('controller'=>'student_resumes', 'action' => 'add', $student['Student']['id']),
                    array('class' => 'button attention')));
                ?>
            <?php else: ?>
                <p><?php __('No application, got to quick action section for recent jobs'); ?></p>
            <?php endif; ?>
        <?endif; ?>
        </div>
    </div>
</div>
<br class="clear">

<?php //debug($student); ?>

<script type='text/javascript'>
jQuery(function(){
    /* Bind job introduction and requirement toggler */
    $('ul.tabs').tabs('div.panes > div.job_content');
    /* Ajax anti apply */
    $('div#widget_students_jobs a.link_delete_student_job').click($.sme.cbk.ajaxAntiApply);
    $('div#widget_students_jobs a.link_apply_for_the_job').click($.sme.cbk.ajaxApply);
});
</script>
